package com.gwcloud.leetcode.offers;

import java.util.HashMap;

import com.gwcloud.leetcode.common.datastructure.Node138;

/** 
* @ClassName   : Leetcode0350 
* @author      : ganwei 
* @date        : 2020年6月4日 
* @Description : TODO 
*/
public class Leetcode0350 {
    /**
     * -解题思路,利用HashMap
     */
	public Node138 copyRandomList(Node138 head) {
        HashMap<Node138,Node138> map = new HashMap<Node138,Node138>(); 
        Node138 index = head;
        while(index != null) {
        	map.put(index, new Node138(index.val));
        }
        
        Node138 index1 = head;
        while(index1 != null) {
        	Node138 curn = map.get(index1); 
        	curn.next = map.get(index1.next);
        	curn.random = map.get(index1.random);        	
        }
        
    	return map.get(head);
    }
    
    /**
     * -主函数
     */
    public static void main(String[] args) {
    	
    }
}
